Skip to content

Support for custom keywords#1031

Open
louis-lau wants to merge 7 commits intozone-eu:masterfrom
getSilvabird:keywords
Open

Support for custom keywords#1031
louis-lau wants to merge 7 commits intozone-eu:masterfrom
getSilvabird:keywords

Conversation

@louis-lau
Copy link
Copy Markdown
Contributor

This has been a long time coming, finally found the motivation recently :)

This PR adds support for custom keywords (which are just flags). You can use these to represent labels in a webmail (#763), and sync those same labels with for example Thunderbird over IMAP.

Overview:

  • Added keywords array to message CRUD
  • Added endpoint to compute counters for a keyword, using redis and deltas in the same manner as mailbox counters
  • Once that endpoint has been called and the value is in redis, keyword counters will be emitted over sse (KEYWORD_COUNTERS) for that keyword. Implemented it this way to avoid computing counters for irrelevant keywords IMAP clients might add
  • Keywords also added to sse events related to message creates/updates. keywords on EXISTS, and addedKeywords and removedKeywords on FETCH
  • Added seperate endpoint to compute counters for flagged messages. Given \flagged is a system flag it shouldn't be part of custom keywords, but knowing the total/unread for flagged messages is still very helpful
  • Also added SSE for that (FLAGGED_COUNTER)
  • No changes to IMAP or indexes, this was already fully supported

Some things:

  • The current flag update code didn't allow for both deleting and adding flags in the same call, it would for example error if you set/unset both seen and deleted in the same api call. This is a MongoDB limitation, you can't use $addToSet and $pull in the same query. I switched it over to a simple aggregation pipeline that does allow for this.
  • Setting draft set flagged in the db for some reason? Assuming that's wrong and fixed
  • There were no tests for filter actions, so while I was there I added tests for all existing actions as well

I normally only work on modern TS codebases, so JS plus the old callback style isn't too familiar for me. Let me know if you see any obvious mistakes :)

@NickOvt
Copy link
Copy Markdown
Contributor

NickOvt commented Mar 23, 2026

Hello Louis!

Thank you for your PR!

I have a quick question, does this PR implement just keywords (IMAP standard) or labels similar
to those used by gmail and other email clients (not standard IMAP)?

Best regards
Nick

@louis-lau
Copy link
Copy Markdown
Contributor Author

louis-lau commented Mar 23, 2026

Just keywords, but that's enough to quite easily implement labels in your webmail. I've implemented labels in our webmail using this :)

Since labels aren't an IMAP server feature, I didn't feel like it was in scope for wildduck, but keywords are.

@louis-lau
Copy link
Copy Markdown
Contributor Author

Ah something I forgot to say is that I of course added a keyword filter to the message search endpoint. So you can actually list messages for a keyword. That together with counters makes it usable as labels within a webmail

@NickOvt NickOvt requested review from NickOvt and andris9 and removed request for andris9 March 23, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants